package com.zhxx.book.controller;

import com.zhxx.book.entity.Teacher;
import com.zhxx.book.service.ITeacherService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 教师信息
 * @Author Alex
 * @Date 2022-11-14 11:16
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController {
   @Autowired
   private ITeacherService teacherService;

   @GetMapping
   public List<Teacher> list() {
      return teacherService.list();
   }

   @PostMapping
   public Boolean add(@RequestBody Teacher teacher) {
      return teacherService.save(teacher);
   }

   @PutMapping
   public Boolean update(@RequestBody Teacher teacher) {
      return teacherService.updateById(teacher);
   }

   @DeleteMapping("/{id}")
   public Boolean delete(@PathVariable Long id) {
      return teacherService.removeById(id);
   }
}
